import { noNull, logs } from "../common/func"

export default (componentName, proxy) => {
	if (!noNull(componentName)) {
		logs(`无当前组件=>${componentName}`)
		return null
	};
	if (proxy.$refs[componentName]) {
		return proxy.$refs[componentName]
	}
	let component = proxy.$parent
	if (!component) {
		logs(`无当前组件=>${componentName}`)
		return null
	}
	for (let i = 1; i <= 9; i++) {
		if (component.$refs && component.$refs[componentName]) {
			return component.$refs[componentName]
		}
		try {
			component = component.$parent
		} catch (ex) {
			component = null
		}
		if (!component) {
			logs(`无当前组件=>${componentName}`)
			return null
		}
	}
	logs(`无当前组件=>${componentName}`)
	return null

}
